package com.edmond.service.impl;

import com.edmond.entity.Goods;
import com.edmond.mapper.GoodsMapper;
import com.edmond.service.IGoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsService implements IGoodsService {
    @Resource()
    private GoodsMapper goodsMapper;

    @Override
    public List<Goods> list() {
        return goodsMapper.findAll();
    }

    @Override
    public Goods find(Integer goodsId) {
        return goodsMapper.find(goodsId);
    }

    @Override
    public int insert(Goods goods) {
        return goodsMapper.add(goods);
    }

    @Override
    public int update(Goods goods) {
        return goodsMapper.update(goods);
    }

    //  随机查询业务实现
    @Override
    public List<Goods> findRandLimit(Integer size) {
        return goodsMapper.findRandLimit(size);
    }

    //  根据类别查询的实现类
    @Override
    public List<Goods> findByCategory(Integer categoryId) {
        return goodsMapper.findByCategory(categoryId);
    }

    //  新增删除功能
    @Override
    public Integer delete(Integer goodsId) {
        return goodsMapper.remove(goodsId);
    }
}
